package com.loren.demo10.aspect;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Aspect
@Component
@RequiredArgsConstructor
public class ParamAspect {

    @Before("@annotation(com.loren.demo10.aspect.Param)")
    public void doBefore(JoinPoint joinPoint) {
        Object[] args = joinPoint.getArgs();
        Object arg1 = args[1];
        @SuppressWarnings("unchecked")
        Map<String, Object> newArg1 = (Map<String, Object>) arg1;
        newArg1.put("name", "Loren77");
    }
}
